package com.coocaa.ops.plus.core.base;

import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author bijiahao
 * @date : 2019/8/5.
 * @description 基础的ftl页面跳转类
 *
 */
public abstract class BaseFtlAction {

    public ModelAndView renderView(HttpServletRequest request, String viewName, Map<String, Object> map) {
        ModelAndView mav = new ModelAndView();
        mav.setViewName(viewName);
        mav.addAllObjects(map);
        return mav;
    }

    public ModelAndView renderView(HttpServletRequest request, String viewName) {
        Map<String, Object> map = new HashMap<String, Object>();
        return renderView(request, viewName, map);
    }

    public ModelAndView renderRedirect(HttpServletRequest request, String viewName) {
        return new ModelAndView("redirect:" + viewName);
    }


}
